/*
 * @Author: 小花
 * @Date: 2022-04-07 09:08:04
 * @LastEditors: 小花
 * @LastEditTime: 2022-04-17 21:05:31
 * @FilePath: /vue3-teap/src/plugins/request/status.ts
 * @Description:
 */

/**
 * @description: 常见状态码消息
 * @param {number} status 状态码 ｜ 字符串
 * @return {*} 消息
 */
export const showMessage = (status: number | string): string => {
  if (!isNaN(parseInt(status as string))) status = parseInt(status as string)
  let message = ''
  switch (status) {
    case 400:
      message = '请求错误(400)'
      break
    case 401:
      message = '未授权，请重新登录(401)'
      break
    case 403:
      message = '拒绝访问(403)'
      break
    case 404:
      message = '请求出错(404)'
      break
    case 405:
      message = '频繁操作(405)'
      break
    case 408:
      message = '请求超时(408)'
      break
    case 500:
      message = '服务器错误(500)'
      break
    case 501:
      message = '服务未实现(501)'
      break
    case 502:
      message = '网络错误(502)'
      break
    case 503:
      message = '服务不可用(503)'
      break
    case 504:
      message = '网络超时(504)'
      break
    case 505:
      message = 'HTTP版本不受支持(505)'
      break
    default:
      message = `连接出错(${status})!`
  }
  return `${message}，请稍候再试.`
}
